<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<link rel="stylesheet" type="text/css" href="gpfw_layout.css"
			media="all" />
		<link rel="stylesheet" type="text/css" href="gpfw_color.css"
			media="all">
		<link rel="stylesheet" type="text/css"
			href="gpfw_font-size_medium.css" media="all" />
		<link rel="stylesheet" type="text/css" href="gpfw_print.css"
			media="print" />
		<script type="text/javascript" src="gpfw.js">
</script>
		<script type="text/javascript" src="js/jquery-1.4.4.js"
			charset="utf-8">
</script>
		<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"
			charset="utf-8">
</script>




	</head>

	<body>
		<table class="azmainFrame" cellspacing="0" cellpadding="0">
			<tr>
				<td class="azgyom">
					<table class="azpalette" cellpadding="0" cellspacing="0">
						<tr>
							<td class="azpalette">
								<table class="aztileLarge" cellspacing="0" cellpadding="0">
									<tr>
										<td>
											<ragSUBMIT1 " cellpadding="0" cellspacing="0"
												style="display:inline-table;">
											

											<s:fielderror cssStyle="color:red;" />

											<table width="440" border="1">
												<tr>
													<td>
														注册前请先阅读
													</td>
													<td>
														<a href="agreement.jsp">校园二手交易网协议</a>
													</td>
												</tr>
											</table>
											<table width="250" border="1">
												<tr>
													<td>
														如果您已注册，请点此登录
													</td>
													<td>
														<a href="login.jsp">登录</a>
													</td>
												</tr>
											</table>
												<input type="hidden" name="username1" value="">
											<s:form action="register" id="register" method="post">
												<table>
													<tr>
														<td>
															<s:textfield name="user.username" id="username" key="用户名"></s:textfield>
															<s:textfield name="user.telephone" id="telephone"
																key="手机号码"></s:textfield>
															<s:password name="user.password" id="password" key="密码"></s:password>
															<s:password name="user.repassword" id="repassword"
																key="再次输入密码"></s:password>
															<s:hidden name="user.login" value="2"></s:hidden>
														</td>
													</tr>
													<tr>
														<td>
															<input type="button" value="注册校园二手交易网"
																onclick="submit1()" />
														</td>
													</tr>
													
												</table>
											</s:form>
	</body>
	<script type="text/javascript">
		function submit1() {
		     var username1 = $("#username1").val();
			 var username = $("#username").val();
			 var telephone = $("#telephone").val();
			 var password = $("#password").val();
			 var repassword = $("#repassword").val();
		       
			if (username == null || username == '' || telephone == null
					|| telephone == '' || password == null || password == ''
					|| repassword == null || repassword == '') {
				alert("以下都是必填项，请全部填写详细资料！");
				return;
			} else {
			         if(username==username1){alert("用户名已存在！");return;}
				     if (password != repassword) {
					alert("密码输入不一致");
					return;
				}
				
				
				
		
				alert("注册成功！正在跳入登录页面")
				$("#register").submit();
		
			}
		}
		function userExist(username) {
			var result="";
			$.post("/json/selectuserbyname.action" ,{
				username : username
			}, function(data) {
			result=data.username;
			$(result).appendTo("#username1");	
			}, 'json');
		
		}
	</script>
</html>
